
package com.example.cia.database.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.example.cia.database.mysql.dao.impl.queryDeviceInfo;

import net.sf.json.JSONObject;

public class getDeviceServlet extends HttpServlet{

	/**
	 * 获取设备信息servlet
	 */
	private static final long serialVersionUID = 6824207867166271922L;

	public void doGet(HttpServletRequest request,HttpServletResponse response)
		throws ServletException,IOException{
		String id = request.getParameter("id");
		
		//从数据库中获取数据
		queryDeviceInfo qdi = new queryDeviceInfo();
		try {
			List<String> paramList = qdi.getInfo(id);
			String jsonResult = "{'1':'"+paramList.get(0)+"','2':'"+paramList.get(1)+"','3':'"+paramList.get(2)+"'}";
			response.setCharacterEncoding("UTF-8");
			response.setContentType("text/html");
			PrintWriter out = response.getWriter();
			out.print(jsonResult);
			out.flush();
			out.close();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public void doPost(HttpServletRequest request,HttpServletResponse response)
		throws ServletException,IOException{
		
	}

}
